/*
 * Copyright Hundsun Technologies Inc. All Rights Reserved.
 */

package p2p

import (
	"fmt"

	"hundsun.com/hsl/hschain/common/config"
	"hundsun.com/hsl/hschain/module"
)

// NewP2pModule 新建一个p2p模块
func NewP2pModule() module.Module {
	p2pType := config.GetStringConfigValue("p2p.pluginType", "")
	if p2pType == "" {
		panic(fmt.Sprintln("p2p type is nil."))
	}
	fn, err := load(p2pType)
	if err != nil {
		panic(fmt.Sprintln("p2p module", "load p2p type", p2pType, "fail", err))
	}
	return fn()
}
